package com.hxgis.oc.product.png;

import com.hxgis.oc.product.base.ConvertTask;
import com.hxgis.oc.util.PNGConvert;
import lombok.Setter;

import java.io.File;
import java.util.function.Function;

public class PngConvTask extends ConvertTask {
    @Setter
    protected Function<File, PNGConvert> convFunc;

    public PngConvTask(Long workID, String ds, File fileToConvert) {
        super(workID, ds);
        inputFile = fileToConvert;
    }

    @Override
    public boolean producing() {
        if(convFunc != null){
            PNGConvert pngConvObj = convFunc.apply(inputFile);
            if(pngConvObj != null){
                pngConvObj.write(outputFile);
                return outputFile.exists();
            }
        }
        return false;
    }

}
